package top.leoseven.adminproject.view.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;


/**
 * Created by admin2 on 2018/4/11.
 */

public class SocketService extends Service {
    private WebSocketClient client;
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
//        client=new AppClient(URI.create("ws://192.168.2.104/websocket/2013121078"),new Draft_17());
//        client.connect();
    }
    class AppClient extends WebSocketClient{

        public AppClient(URI serverURI) {
            super(serverURI);
        }

        public AppClient(URI serverUri, Draft draft) {
            super(serverUri, draft);
        }

        public AppClient(URI serverUri, Draft draft, Map<String, String> headers, int connecttimeout) {
            super(serverUri, draft, headers, connecttimeout);
        }

        @Override
        public void onOpen(ServerHandshake handshakedata) {
            Log.e("SocketService",handshakedata.getHttpStatus()+"");


        }

        @Override
        public void onMessage(String message) {

        }

        @Override
        public void onClose(int code, String reason, boolean remote) {

        }

        @Override
        public void onError(Exception ex) {

        }
    }
}
